/**
 * Created by ml on 2017/5/4.
 */
/*function jqchk(fieldName){ //jquery获取复选框值
    var str = "";
    $('input[name='+fieldName+']:checked').each(function(){
        str += $(this).val() + ",";
    });
    return str.substring(0,str.length-1);
    //alert(str = "" ?'你还没有选择任何内容！':str);
}
function setCheckBox(listName,fieldName){
    var list = $("#"+listName).val().split(",");
    for(var i=0;i<list.length;i++){
        $("input[name="+fieldName+"]").each(function(){
            if($(this).val() == list[i]){
                $(this).attr("checked",true);
            }
        })
    }
}*/


$(function(){
    $("#form-member-add").validate({
        rules:{
            topic:{
                required:true
            },
            /* activityUrl:{
                 required:true
             },*/
            name:{
                required:true
            },
            start:{
                required:true
            },
            end:{
                required:true
            },
        },
        onkeyup:false,
        focusCleanup:true,
        success:"valid",
        submitHandler:function(form){
            $("#form-member-add").ajaxSubmit({
                cache:true,
                type:'POST',
                dataType: 'json',
                data:$('#form-member-add').serialize(),
                url:'/admin/activity/modifyActivity.html',
                async: false,
                success:function(data){
                    console.log(data);
                   if (data.code != 1){
                        layer.msg(data.msg,{icon : 5,time : 1000});
                        console.log(data.msg);
                        return;
                    }
                    layer.msg('操作成功!',{icon : 6,time : 1000},function(){
                        window.parent.location.reload();
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                    })
                }
            })
        }
    });
});